<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //Symbol可接受一个参数用作Symbol的描述，方便我们区分
        let keys = {
            name: Symbol("name"),
            age: Symbol("age"),
            location: Symbol("location"),
            test: Symbol("test")
        }
        let obj = {
            [keys.name]: "twj",
            [keys.age]: 100,
            [keys.location]: "beijing",
            [keys.test]() {
                console.log("test")
            }
        }
        obj.name = "aaaaaa"
        console.log(obj) //{name: 'aaaaaa', Symbol(name): 'twj', Symbol(age): 100, Symbol(location): 'beijing', Symbol(test): ƒ}

        //for..in 只能遍历出普通的属性
        for (let i in obj) {
            console.log(i) //name
        }
        //遍历得到Symbol的属性
        console.log(Object.getOwnPropertySymbols(obj)) //[Symbol(name), Symbol(age), Symbol(location), Symbol(test)]

        console.log(Reflect.ownKeys(obj)) //['name', Symbol(name), Symbol(age), Symbol(location), Symbol(test)]
        //遍历得到所有属性
        Reflect.ownKeys(obj).forEach(item => {
            console.log(item, obj[item])
        })


    </script>
</body>

</html>